home *** CD-ROM | disk | FTP | other *** search
/ Suzy B Software 2 / Suzy B Software CD-ROM 2 (1994).iso / extras / falcon / dsptrack / tracker.asm < prev    next >
Assembly Source File  |  1995-04-27  |  7KB  |  356 lines

  1. ;***********************************************************************
  2. ;***********                                         ***********
  3. ;***********                                         ***********
  4. ;***********        Routine de Replay Soundtracker         ***********
  5. ;***********              2 + 2 * x  voies                 ***********
  6. ;***********                                         ***********
  7. ;***********         Transmission par port Host             ***********
  8. ;***********           Routine en Host Command             ***********
  9. ;***********                                         ***********
  10. ;***********           Par Simplet / ABSTRACT             ***********
  11. ;***********                                         ***********
  12. ;***********************************************************************
  13.  
  14.  
  15. PBC        equ        $ffe0            ; Port B Control Register
  16. PCC        equ        $ffe1            ; Port C Control register
  17. HCR        equ        $ffe8            ; Host Control Register
  18. HSR        equ        $ffe9            ; Host Status Register
  19. HRX        equ        $ffeb            ; Host Receive Register
  20. HTX        equ        $ffeb            ; Host Transmit Register
  21. CRA        equ        $ffec            ; SSI Control Register A
  22. CRB        equ        $ffed            ; SSI Control Register B
  23. SSISR    equ        $ffee            ; SSI Status Register
  24. TX        equ        $ffef            ; SSI Serial Transmit data/shift register
  25. IPR        equ        $ffff            ; Interrupt Priority Register
  26.  
  27. ;    Host Control Register Bit Flags
  28.  
  29. HCIE        equ        2                ; Host Command Interrupt Enable
  30.  
  31. ;    Host Status Register Bit Flags
  32.  
  33. HRDF        equ        0                ; Host Receive Data Full
  34. HTDE        equ        1                ; Host Transmit Data Empty
  35.  
  36.  
  37.         org        p:$0
  38.         jmp        Start
  39.  
  40.         org        p:$10
  41.         jsr        Spl_Out
  42.  
  43.         org        p:$26
  44.         jsr        Soundtrack_Rout
  45.  
  46.         org        p:$28                ; Pas de SSI
  47.         movep    #$0800,X:<<IPR            ; Host au niveau 2
  48.  
  49.  
  50. ; Routine sous interruption de Replay du son par le SSI
  51.  
  52.         org        p:$40
  53.  
  54. Spl_Out    jset        #<2,X:<<SSISR,Right_Out    ; Détecte le premier transfert
  55.  
  56. Left_Out    movep    X:(r7),X:<<TX
  57.         rti
  58. Right_Out    movep    Y:(r7)+,X:<<TX
  59.         rti
  60.  
  61. ;
  62. ; Ca commence la :
  63. ;
  64.  
  65. Start    movep    #1,X:<<PBC            ; Port B en Host
  66.         movep    #$1f8,X:<<PCC            ; Port C en SSI
  67.         movep    #$4100,X:<<CRA            ; 1 voie 16 bits Stereo
  68.         movep    #$5800,X:<<CRB            ; autorise l'IT d'émission
  69.         movep    #$3800,X:<<IPR            ; le SSI au niveau d'IT 3
  70.                                     ; et le Host en IPL 2
  71.         bset        #HCIE,X:<<HCR            ; Autorise ITs Host Command
  72.  
  73.  
  74. ; Initialisations Registres
  75.  
  76.         move        #-1,m0
  77.         move        #3699,m7
  78.         move        m0,m1
  79.         move        m7,m6
  80.         move        #>1400,n4
  81.         move        m0,m4
  82.  
  83. ; Efface le buffer
  84.         clr        b
  85.         move        #SampleBuffer,r0
  86.  
  87.         DO        #3700,Clear_Sample
  88.         move        b,X:(r0)
  89.         move        b,Y:(r0)+
  90. Clear_Sample
  91.  
  92.  
  93. ; Pour vérifier la connexion
  94.  
  95. Conct_Get    jclr        #<HRDF,X:<<HSR,Conct_Get
  96.         movep    X:<<HRX,x0
  97.  
  98. Conct_Snd    jclr        #<HTDE,X:<<HSR,Conct_Snd
  99.         movep    #12345678,X:<<HTX
  100.  
  101.  
  102.         move        #SampleBuffer,r7
  103.  
  104. ; Autorise les interruptions (IPL0)
  105.         andi        #<%11111100,mr
  106.  
  107. ;
  108. ; Boucle principale qui ne fait strictement rien
  109. ;
  110.  
  111. Loop        jmp        <Loop
  112.  
  113. ;
  114. ; Routine SoundTracker en Host Command
  115. ;
  116.  
  117. Soundtrack_Rout
  118.         jclr        #<HRDF,X:<<HSR,Soundtrack_Rout
  119.         movep    X:<<HRX,a
  120.         move        a1,X:<Length
  121.  
  122. Get_NbVox    jclr        #<HRDF,X:<<HSR,Get_NbVox
  123.         movep    X:<<HRX,X:Nb_Voices_Sup
  124.  
  125.         move        X:<CalcNext,x0
  126.         move        x0,X:<Calc
  127.         move        r7,X:<CalcNext
  128.  
  129.  
  130. ; Recoie les deux premieres voies
  131.  
  132.         move        #Voice_1,r0
  133.         jsr        <Receive_Voice_Left
  134.         move        #Voice_2,r0
  135.         jsr        <Receive_Voice_Right
  136.  
  137. ; Recoie les x autres paires de voies supplementaires
  138.  
  139.         move        #Voices_Sup,r4
  140.         DO        X:<Nb_Voices_Sup,Receive_Voices_Sup
  141.  
  142.         move        r4,r0
  143.         jsr        <Receive_Voice_Left
  144.         move        r4,r0
  145.         jsr        <Receive_Voice_Right
  146.  
  147.         lua        (r4)+n4,r4
  148. Receive_Voices_Sup
  149.  
  150. ; Calcule les deux premieres voies
  151.  
  152.         move        #Voice_1,r0
  153.         jsr        <Calc_Voice_Left
  154.         move        #Voice_2,r0
  155.         jsr        <Calc_Voice_Right
  156.  
  157. ; Mixe les x autres paires de voies supplementaires
  158.  
  159.         move        #Voices_Sup,r4
  160.         DO        X:<Nb_Voices_Sup,Mix_Voices_Sup
  161.  
  162.         move        r4,r0
  163.         jsr        <Mix_Voice_Left
  164.         move        r4,r0
  165.         jsr        <Mix_Voice_Right
  166.  
  167.         lua        (r4)+n4,r4
  168. Mix_Voices_Sup
  169.  
  170.         rti
  171.  
  172.  
  173. ; Routine de réception d'infos voie et sample à Gauche
  174.  
  175. Receive_Voice_Left
  176. Receive_Left_Volume
  177.         jclr        #<HRDF,X:<<HSR,Receive_Left_Volume
  178.         movep    X:<<HRX,X:(r0)+
  179. Receive_Left_Frequence
  180.         jclr        #<HRDF,X:<<HSR,Receive_Left_Frequence
  181.         movep    X:<<HRX,x0
  182.         move        x0,X:(r0)+
  183.         move        X:<Length,x1
  184.         mpy        x0,x1,a        (r0)+
  185. Send_Left_Length
  186.         jclr        #<HTDE,X:<<HSR,Send_Left_Length
  187.         movep    a1,X:<<HTX
  188. Receive_Left_Length
  189.         jclr        #<HRDF,X:<<HSR,Receive_Left_Length
  190.         movep    X:<<HRX,b
  191.  
  192.         lsl        b    #>$80,y0
  193.         move            #>$8000,y1
  194.  
  195.         DO        b1,Receive_Left_Loop
  196. Receive_Left_Sample
  197.         jclr        #<HRDF,X:<<HSR,Receive_Left_Sample
  198.         movep    X:<<HRX,x0
  199.         mpy        x0,y0,a        x0,X:(r0)+
  200.         mpy        x0,y1,a        a0,X:(r0)+
  201.         move        a0,X:(r0)+
  202. Receive_Left_Loop
  203.         rts
  204.  
  205. ; Routine de calcul de la premiere voie a Gauche
  206.  
  207. Calc_Voice_Left
  208.         move        X:<Calc,r6        ; Adresse
  209.         move        X:(r0)+,x1        ; Volume
  210.         lua        (r0)+,r1
  211.         move        X:(r0)+,y1        ; Fréquence
  212.         move        X:(r1)+,b            ; Fractionnaire
  213.  
  214.         move        X:(r1),x0            ; Premier
  215.         mpy        x0,x1,a            ; Sample
  216.  
  217.  
  218.         DO        X:<Length,Calc_Voice_Left_Loop
  219.  
  220.         add        y1,b
  221.         jec        <CL_NoNext
  222.         bclr        #23,b1
  223.         move        X:(r1)+,x0
  224.         mpy        x0,x1,a
  225. CL_NoNext    move        a1,X:(r6)+
  226.  
  227. Calc_Voice_Left_Loop
  228.         move        b,X:(r0)
  229.         rts
  230.  
  231. ; Routine de calcul d'une voie supplémentaire à Gauche
  232.  
  233. Mix_Voice_Left
  234.         move        X:<Calc,r6        ; Adresse
  235.         move        X:(r0)+,x1        ; Volume
  236.         lua        (r0)+,r1
  237.         move        X:(r0)+,y1        ; Fréquence
  238.         move        X:(r1)+,b            ; Fractionnaire
  239.  
  240.         move        X:(r1),x0            ; Premier Sample
  241.  
  242.  
  243.         DO        X:<Length,Mix_Voice_Left_Loop
  244.  
  245.         add        y1,b                X:(r6),a
  246.         jec        <ML_NoNext
  247.         bclr        #23,b1
  248.         move        X:(r1)+,x0
  249. ML_NoNext    mac        x0,x1,a
  250.         move        a1,X:(r6)+
  251.  
  252. Mix_Voice_Left_Loop
  253.         move        b,X:(r0)
  254.         rts
  255.  
  256. ; Routine de réception d'infos voie et sample à Droite
  257.  
  258. Receive_Voice_Right
  259. Receive_Right_Volume
  260.         jclr        #<HRDF,X:<<HSR,Receive_Right_Volume
  261.         movep    X:<<HRX,Y:(r0)+
  262. Receive_Right_Frequence
  263.         jclr        #<HRDF,X:<<HSR,Receive_Right_Frequence
  264.         movep    X:<<HRX,x0
  265.         move        x0,Y:(r0)+
  266.         move        X:<Length,x1
  267.         mpy        x0,x1,a        (r0)+
  268. Send_Right_Length
  269.         jclr        #<HTDE,X:<<HSR,Send_Right_Length
  270.         movep    a1,X:<<HTX
  271. Receive_Right_Length
  272.         jclr        #<HRDF,X:<<HSR,Receive_Right_Length
  273.         movep    X:<<HRX,b
  274.  
  275.         lsl        b    #>$80,y0
  276.         move            #>$8000,y1
  277.  
  278.         DO        b1,Receive_Right_Loop
  279. Receive_Right_Sample
  280.         jclr        #<HRDF,X:<<HSR,Receive_Right_Sample
  281.         movep    X:<<HRX,x0
  282.         mpy        x0,y0,a        x0,Y:(r0)+
  283.         mpy        x0,y1,a        a0,Y:(r0)+
  284.         move        a0,Y:(r0)+
  285. Receive_Right_Loop
  286.         rts
  287.  
  288. ; Routine de calcul de la premiere voie a Droite
  289.  
  290. Calc_Voice_Right
  291.         move        X:<Calc,r6        ; Adresse
  292.         move        Y:(r0)+,x1        ; Volume
  293.         lua        (r0)+,r1
  294.         move        Y:(r0)+,y1        ; Fréquence
  295.         move        Y:(r1)+,b            ; Fractionnaire
  296.  
  297.         move        Y:(r1),x0            ; Premier
  298.         mpy        x0,x1,a            ; Sample
  299.  
  300.  
  301.         DO        X:<Length,Calc_Voice_Right_Loop
  302.  
  303.         add        y1,b
  304.         jec        <CR_NoNext
  305.         bclr        #23,b1
  306.         move        Y:(r1)+,x0
  307.         mpy        x0,x1,a
  308. CR_NoNext    move        a1,Y:(r6)+
  309.  
  310. Calc_Voice_Right_Loop
  311.         move        b,Y:(r0)
  312.         rts
  313.  
  314. ; Routine de calcul d'une voie supplémentaire à Droite
  315.  
  316. Mix_Voice_Right
  317.         move        X:<Calc,r6        ; Adresse
  318.         move        Y:(r0)+,x1        ; Volume
  319.         lua        (r0)+,r1
  320.         move        Y:(r0)+,y1        ; Fréquence
  321.         move        Y:(r1)+,b            ; Fractionnaire
  322.  
  323.         move        Y:(r1),x0            ; Premier Sample
  324.  
  325.         DO        X:<Length,Mix_Voice_Right_Loop
  326.  
  327.         add        y1,b            Y:(r6),a
  328.         jec        <MR_NoNext
  329.         bclr        #23,b1
  330.         move        Y:(r1)+,x0
  331. MR_NoNext    mac        x0,x1,a
  332.         move        a1,Y:(r6)+
  333.  
  334. Mix_Voice_Right_Loop
  335.         move        b,Y:(r0)
  336.         rts
  337.  
  338. ; Zone de données
  339.  
  340.             org        X:0
  341.  
  342. Nb_Voices_Sup    DC        1
  343. Length        DS        1
  344. Calc            DC        SampleBuffer
  345. CalcNext        DC        SampleBuffer
  346.  
  347.             org        X:1*1400
  348. Voice_1
  349. Voice_2
  350.             org        X:2*1400
  351. Voices_Sup
  352.  
  353.             org        Y:3*4096
  354. SampleBuffer
  355.             END
  356.